package com.itheima.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.UUID;

@WebServlet("/showAddPage")
public class ShowAddPageServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //TODO:解决重复提交代码
        //1,生成uuid
        String uuid = UUID.randomUUID().toString();
        //2，将uuid存储到session域对象中
        request.getSession().setAttribute("uuid",uuid);
        //跳转到 add.jsp 页面
        request.setAttribute("uuid",uuid);
        request.getRequestDispatcher("/WEB-INF/pages/add.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
